﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SST.Phone">
<!-- http://stackoverflow.com/questions/4196097/how-to-set-wrapping-for-hyperlinkbutton-with-databound-content-text-->
  <Style x:Key="HyperlinkButtonWrappingStyle"
        TargetType="HyperlinkButton">
    <Setter Property="Foreground"
            Value="{StaticResource PhoneForegroundBrush}" />
    <Setter Property="Background"
            Value="Transparent" />
    <Setter Property="FontSize"
            Value="{StaticResource PhoneFontSizeMedium}" />
    <Setter Property="Padding"
            Value="0" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="HyperlinkButton">
          <Border Background="Transparent">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal" />
                <VisualState x:Name="MouseOver" />
                <VisualState x:Name="Pressed">
                  <Storyboard>
                    <DoubleAnimation Duration="0"
                                        To="0.5"
                                        Storyboard.TargetProperty="Opacity"
                                        Storyboard.TargetName="TextElement" />
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Disabled">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                    Storyboard.TargetName="TextElement">
                      <DiscreteObjectKeyFrame KeyTime="0"
                                              Value="{StaticResource PhoneDisabledBrush}" />
                    </ObjectAnimationUsingKeyFrames>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border Background="{TemplateBinding Background}"
                    Margin="{StaticResource PhoneHorizontalMargin}"
                    Padding="{TemplateBinding Padding}">
              <TextBlock x:Name="TextElement"
                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                          Text="{TemplateBinding Content}"
                          TextDecorations="Underline"
                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                          TextWrapping="Wrap" />
            </Border>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>